/* Ejercicio 4.23
   ejer4_23.c */
#include <stdio.h>
#include <math.h>

/* function main begins program execution */
int main( void )
{
   int amount; /* amount on deposit */
   int principal = 100000; /* starting principal */
   double rate = .05; /* annual interest rate */
   int year; /* year counter */

   /* output table column head */
   printf( "%4s%21s\n", "Year", "Amount on deposit" );

   /* calculate amount on deposit for each of ten years */
   for ( year = 1; year <= 10; year++ ) {

      /* calculate new amount for specified year */
      amount = ( int ) ( principal * pow( 1.0 + rate, year ) );

      /* output one table row */
      printf( "%4d%18d.%02d\n", year, amount / 100, amount % 100 );
   } /* end for */

   return 0; /* indicate program ended successfully */
} /* end function main */
